//
//  LZTagButton.m
//  LZHundredJie
//
//  Created by apple on 16/5/8.
//  Copyright © 2016年 m14a.cn. All rights reserved.
//

#import "LZTagButton.h"

@implementation LZTagButton

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = LZTagBgColor;
        [self setImage:[UIImage imageNamed:@"chose_tag_close_icon"] forState:UIControlStateNormal];
        self.titleLabel.font = [UIFont systemFontOfSize:14.0];
    }
    return self;
}

- (void)setTitle:(NSString *)title forState:(UIControlState)state
{
    [super setTitle:title forState:state];
    // 自动计算
    [self sizeToFit];
    // 微调，高度设置成自己的
    self.height = LZTagH;
    self.width += 3 * LZCommonSmallMargin;
}

- (void)layoutSubviews {

    [super layoutSubviews];

    self.titleLabel.x = LZCommonSmallMargin;
    self.imageView.x = CGRectGetMaxX(self.titleLabel.frame) + LZCommonSmallMargin;
}

@end
